#ifndef _LIBJTAG_H_
#define _LIBJTAG_H_

enum {
  TEST_LOGIC_RESET=0,
  RUN_TEST_IDEL,

  SELECT_DR_SCAN,
  CAPTURE_DR,
  SHIFT_DR,
  EXIT1_DR,
  PAUSE_DR,
  EXIT2_DR,
  UPDATE_DR,

  SELECT_IR_SCAN,
  CAPTURE_IR,
  SHIFT_IR,
  EXIT1_IR,
  PAUSE_IR,
  EXIT2_IR,
  UPDATE_IR,

  JTAG_STAT_COUNT
};

static inline unsigned char inb(unsigned short port)
{
  unsigned char data;
  
  __asm__ __volatile__ ("inb %1 %0":"=a"(data):"d"(port));

  return data;
}

static inline unsigned short inw(unsigned short port)
{
  unsigned short data;

  __asm__ __volatile__ ("inw %1 %0":"=a"(data):"d"(port));

  return data;
}

static inline unsigned int inl(unsigned short port)
{
  unsigned int data;

  __asm__ __volatile__ ("inl %1 %0":"=a"(data):"d"(port));

  return data;
}

static inline unsigned char outb(unsigned char data, unsigned short port)
{
  __asm__ __volatile__ ("outb %0 %1"::"a"(data),"d"(port));

  return data;
}

static inline unsigned short outw(unsigned short data, unsigned short port)
{
  __asm__ __volatile__ ("outw %0 %1"::"a"(data),"d"(port));

  return data;
}

static inline unsigned int outl(unsigned int data, unsigned short port)
{
  __asm__ __volatile__ ("outl %0 %1"::"a"(data),"d"(port));

  return data;
}

#endif
